package com.design.strategy.supermarket;

import java.io.File;

/**
 * Created by yijy on 2018/1/16.
 */
public class TestMarket {
    public static void main(String[] args) {
        PriceContext context = new PriceContext(1,400f);
        System.out.println(context.executePriceStrategy());
        context = new PriceContext(2,400f,0.8f);
        System.out.println(context.executePriceStrategy());
        context = new PriceContext(3,400f,300,80);
        System.out.println(context.executePriceStrategy());
//        new TestMarket().toPath();
        System.out.println(getSubject("10","20"));
    }

    public void toPath() {
        String str = System.getProperty("os.name").substring(0,3).toUpperCase();
        String path=null;
        if("WIN".equals(str)){
            path = this.getClass().getResource("/").getPath();
        }else {
            path=Thread.currentThread().getContextClassLoader().getResource("/").getPath();
        }
        System.out.println(path+ File.separator);
    }

    public static String getSubject(String ...args){
        int i = 0;
        String str = "";
        while (i<args.length){
            if(!"".equals(args[i]) && null!=args[i]){
                if("".equals(str))
                    str = args[i];
                else
                    str += "," + args[i];
            }
            i++;
        }
        return str;
    }


}
